﻿#include "myvector.h"

namespace real
{
    void testvector1()
    {
        cout << "testing" << endl;
        vector<int> iv ;
        iv.push_back(1) ;
        iv.push_back(2) ;
        iv.push_back(3) ;
        iv.push_back(4) ;
        iv.push_back(5) ;
        iv.push_back(6) ;
        iv.push_back(7) ;
        iv.push_back(8) ;
        iv.push_back(9) ;
        cout << iv[0] << " size:" << iv.size() << endl;
        print_vector(iv);

        vector<int> iv2 = iv;
        iv2.push_back(119) ;
        print_vector(iv2);
    }

    void testvector2()
    {
        cout << "================testing================" << endl;
        vector<int> iv =1;
        iv.push_back(2) ;
        iv.push_back(3) ;
        iv.push_back(4) ;
        iv.push_back(5) ;
        iv.push_back(6) ;
        print_vector(iv);
        iv.pop_back();
        print_vector(iv);
        iv.pop_back();
        iv.pop_back();
        iv.pop_back();
        print_vector(iv);
    }

    void testvector3()
    {
        cout << "================testing================" << endl;
        vector<int> iv(1);
        iv.push_back(2) ;
        iv.push_back(3) ;
        iv.push_back(4) ;
        iv.push_back(5) ;
        iv.push_back(6) ;
        iv.insert(iv.begin()+2, 100);
        print_vector(iv);

        typename vector<int>::iterator pos = std::find(iv.begin(), iv.end(), 5);
        iv.insert(pos, 300);
        print_vector(iv);

        pos = std::find(iv.begin(), iv.end(), 6);
        iv.erase(pos);
        print_vector(iv);

    }

    void testvector4()
    {
        cout << "================testing4================" << endl;
        vector<int> iv;
        iv.push_back(1) ;
        iv.push_back(2) ;
        iv.push_back(3) ;
        iv.push_back(4) ;
        iv.push_back(5) ;

        cout << "start copy struct" << endl;
        vector<int> iv2 = iv;
        print_vector(iv2);
    }

    void testvector5()
    {
        cout << "================testing5================" << endl;
        std::list<int> il;
        il.push_back(1) ;
        il.push_back(2) ;
        il.push_back(3) ;
        il.push_back(4) ;
        il.push_back(5) ;
        print_container(il);

        vector<int> iv(il.begin(), il.end());
        print_container(iv);

        vector<int> iv2;
        iv2 = iv;
        // print_container(iv2);
        print_vector(iv2);
    }

    void testvector6()
    {
        cout << "================testing6================" << endl;
        vector<double> iv(15, 100.0);
        print_vector(iv);
        
        cout << "----------------------------------------" << endl;
        vector<int> iv2(10);
        print_vector(iv2);

        cout << "----------------------------------------" << endl;
        vector<int> iv3(10, 5);
        print_vector(iv3);
    }

    void testvector7()
    {
        cout << "================testing7================" << endl;
        vector<std::string> iv;
        iv.push_back("hello");
        iv.push_back("world");
        iv.push_back("vector");
        iv.push_back("string");
        print_container(iv);
        iv.push_back("string");
        print_container(iv);
    }
}

int main()
{
    // real::testvector1();
    // real::testvector2();
    // real::testvector3();
    // real::testvector4();
    // real::testvector5();
    // real::testvector6();
    real::testvector7();
    return 0;
}